package de.szut.logic;

import de.szut.interfaces.IResearch;
import de.szut.util.OperatingSystemName;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: dzebcuks
 * Date: 08.10.13
 * Time: 13:41
 * To change this template use File | Settings | File Templates.
 */
public class Research implements IResearch,Serializable{
    public static final double PROGRESS_DONE = 100.0;

    private boolean isStarted;

    private double process;

    private OperatingSystemName osName;

    public Research(OperatingSystemName operatingSystemName){
        this.isStarted = false;
        this.process = 0.0;
        this.osName = operatingSystemName;
    }

    @Override
    public boolean isStarted() {
        return this.isStarted;
    }

    @Override
    public void start() {
        this.isStarted = true;
    }

    @Override
    public void process(Double resistanceRate) {
        this.process += 2 / resistanceRate;
        if(this.process > Research.PROGRESS_DONE){
            this.process = Research.PROGRESS_DONE;
        }
    }

    @Override
    public double getResearchProcess() {
        return this.process;
    }

    @Override
    public OperatingSystemName getOperatingSystem() {
        return this.osName;
    }
}
